<%--

 Lets you interactively view your WebQuilt proxy log file.
 
 This software is distributed under the Berkeley Software License.
   See "http://guir.cs.berkeley.edu/projects/COPYRIGHT.txt" for details.

 author: Jeffrey Heer 2/01 - jheer@hkn.eecs.berkeley.edu

--%>
<%@ page import="java.io.*"                                                      %>
<%@ page import="edu.berkeley.guir.webquilt.*"                                   %>
<%@ page import="edu.berkeley.guir.webquilt.proxy.WebQuiltLogEntry"              %>
<%
	String             strTaskID   = (String)session.getAttribute("TASKID");
	String             strUserID   = (String)session.getAttribute("USERID");
%>
<HTML>
<HEAD>
  <TITLE>WebQuilt Log Viewer</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<H1>WebQuilt Log - Session <%= session.getId() %></H1>
<H2>&nbsp;Task <%= strTaskID %> - User <%= strUserID %></H2>
<PRE>
<%= WebQuiltLogEntry.getLogHeader() %>

<%
    try {
	HttpServletRequest req     = (HttpServletRequest) request;
	String             strFile = WebQuiltLib.getLogFileName(strTaskID, strUserID);
	
	File logfile = new File(strFile);
	if ( ! logfile.exists() ) {
	    out.println("Sorry - Log File \"" + strFile + "\" Not Found!!");
	} else {
	    FileInputStream logInStream = new FileInputStream(logfile);
	    String          logStr      = new String(WebQuiltLib.readAllFromInputStream(logInStream));

	    out.println(logStr);
	}
    } catch ( Exception e ) {
	out.println("Sorry - an error occured while processing the log file.");
    }
%>
</PRE>
<A HREF="javascript:window.close();">Close this window</A>
</BODY>
</HTML>
